package cn.iocoder.yudao.module.form.controller;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.form.dataobject.FormChooseChart;
import cn.iocoder.yudao.module.form.service.IFormChooseChartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 报表图表对应Controller
 *
 * @author Fan KaiXiang
 * @date 2022-08-31
 */
@Api(tags = "a报表图表对应表")
@RestController
@RequestMapping("/admin-api/form/choosechart")
public class FormChooseChartController
{
    @Autowired
    private IFormChooseChartService formChooseChartService;

    /**
     * 查询报表图表对应列表
     */
//    @PreAuthorize("@ss.hasPermi('form:choosechart:list')")
    @ApiOperation(value = "获取报表图表对应列表", notes = "获取报表图表对应列表")
    @GetMapping("/list")
    public CommonResult<List<FormChooseChart>> list(FormChooseChart formChooseChart)
    {
//        startPage();
        List<FormChooseChart> list = formChooseChartService.selectFormChooseChartList(formChooseChart);
        return success(list);
    }

    /**
     * 导出报表图表对应列表
     */
//    @PreAuthorize("@ss.hasPermi('form:choosechart:export')")
//    @Log(title = "报表图表对应", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, FormChooseChart formChooseChart)
//    {
//        List<FormChooseChart> list = formChooseChartService.selectFormChooseChartList(formChooseChart);
//        ExcelUtil<FormChooseChart> util = new ExcelUtil<FormChooseChart>(FormChooseChart.class);
//        util.exportExcel(response, list, "报表图表对应数据");
//    }

    /**
     * 获取报表图表对应详细信息
     */
//    @PreAuthorize("@ss.hasPermi('form:choosechart:query')")
    @ApiOperation(value = "根据id获取报表图表对应", notes = "根据id获取报表图表对应")
    @GetMapping(value = "/{id}")
    public CommonResult<FormChooseChart> getInfo(@PathVariable("id") Long id)
    {
        return success(formChooseChartService.selectFormChooseChartById(id));
    }

    /**
     * 新增报表图表对应
     */
//    @PreAuthorize("@ss.hasPermi('form:choosechart:add')")
    @ApiOperation(value = "新增报表图表对应", notes = "新增报表图表对应")
    @PostMapping
    public CommonResult<Integer> add(@RequestBody FormChooseChart formChooseChart)
    {
        return success(formChooseChartService.insertFormChooseChart(formChooseChart));
    }

    /**
     * 修改报表图表对应
     */
//    @PreAuthorize("@ss.hasPermi('form:choosechart:edit')")
    @ApiOperation(value = "修改报表图表对应", notes = "修改报表图表对应")
    @PutMapping
    public CommonResult<Integer> edit(@RequestBody FormChooseChart formChooseChart)
    {
        return success(formChooseChartService.updateFormChooseChart(formChooseChart));
    }

    /**
     * 删除报表图表对应
     */
//    @PreAuthorize("@ss.hasPermi('form:choosechart:remove')")
    @ApiOperation(value = "删除报表图表对应", notes = "删除报表图表对应")
	@DeleteMapping("/{ids}")
    public CommonResult<Integer> remove(@PathVariable Long[] ids)
    {
        return success(formChooseChartService.deleteFormChooseChartByIds(ids));
    }
}
